/**
 * Created by spatra on 14-9-17.
 */

define(function(){

	var List = function(jsArray){
		this.innerArray = jsArray || [];
	};

	List.prototype = {
		push: function(add){
			this.innerArray.push(add);
		},

		getInnerArray: function(){
			return this.innerArray;
		},

		deleteByIndex: function(index){
			for(var i = index; i < this.innerArray.length; ++i ){
				this.innerArray[i] = this.innerArray[i+1];
			}

			this.innerArray.length -= 1;
		},

		get: function(index){
			return this.innerArray[index];
		},

		set: function(index, val){
			this.innerArray[index] = val;
		},

		getLength: function(){
			return this.innerArray.length;
		},

		merge: function(otherList, returnResult){
			var tmp = this.innerArray.concat( otherList.innerArray );

			if( returnResult ){
				return new List(tmp);
			}
			else{
				this.innerArray = tmp;
			}
		}
	};

	return List;
});